home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / dev / sun3.md / devFsOpTable.c < prev    next >
C/C++ Source or Header  |  1990-11-03  |  8KB  |  243 lines

  1. /* 
  2.  * devFsOpTable.c --
  3.  *
  4.  *    Initialization of the operation switch tables used for
  5.  *    the FS => DEV interface on Sun3 hosts.
  6.  *
  7.  * Copyright 1987, 1988 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/kernel/dev/sun3.md/RCS/devFsOpTable.c,v 9.3 90/11/03 13:50:58 mgbaker Exp $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21.  
  22. #include "sprite.h"
  23. #include "dev.h"
  24. #include "devInt.h"
  25. #include "fs.h"
  26. #include "rawBlockDev.h"
  27. #include "devFsOpTable.h"
  28. #include "devTypes.h"
  29.  
  30. /*
  31.  * Device specific include files.
  32.  */
  33.  
  34. #include "devSyslog.h"
  35. #include "devNull.h"
  36. #include "devSCSIDisk.h"
  37. #include "devSCSITape.h"
  38. #include "xylogics450.h"
  39. #include "devNet.h"
  40. #include "devTMR.h"
  41. #include "devBlockDevice.h"
  42. #include "devfb.h"
  43. #include "scsiHBADevice.h"
  44. #include "raidExt.h"
  45. #include "tty.h"
  46. #include "mouse.h"
  47.  
  48.  
  49. static ReturnStatus nullOpenProc _ARGS_ ((Fs_Device *devicePtr,
  50.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr));
  51. static ReturnStatus noOpenProc _ARGS_ ((Fs_Device *devicePtr,
  52.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr));
  53. static ReturnStatus nullReadProc _ARGS_ ((Fs_Device *devicePtr,
  54.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr));
  55. static ReturnStatus nullWriteProc _ARGS_ ((Fs_Device *devicePtr,
  56.     Fs_IOParam *writePtr, Fs_IOReply *replyPtr));
  57. static ReturnStatus nullCloseProc _ARGS_ ((Fs_Device *devicePtr,
  58.     int flags, int numUsers, int numWriters));
  59. static ReturnStatus nullSelectProc _ARGS_ ((Fs_Device *devicePtr,
  60.     int *readPtr, int *writePtr, int *exceptPtr));
  61. static ReturnStatus nullReopenProc _ARGS_ ((Fs_Device *devicePtr,
  62.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr));
  63. static ReturnStatus noReopenProc _ARGS_ ((Fs_Device *devicePtr,
  64.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr));
  65. static ReturnStatus noMmapProc _ARGS_ ((Fs_Device *devicePtr,
  66.     Address startAddr, int length, int offset, Address *newAddrPtr));
  67.  
  68.  
  69. /*
  70.  * Device type specific routine table:
  71.  *    This is for the file-like operations as they apply to devices.
  72.  *    DeviceOpen
  73.  *    DeviceRead
  74.  *    DeviceWrite
  75.  *    DeviceIOControl
  76.  *    DeviceClose
  77.  *    DeviceSelect
  78.  *    BlockDeviceAttach
  79.  *    DeviceReopen
  80.  *      DeviceMmap
  81.  */
  82.  
  83.  
  84. DevFsTypeOps devFsOpTable[] = {
  85.     /*
  86.      * Serial lines used to implement terminals.
  87.      */
  88.     {DEV_TERM,       DevTtyOpen, DevTtyRead, DevTtyWrite,
  89.              DevTtyIOControl, DevTtyClose, DevTtySelect,
  90.              DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  91.  
  92.     /*
  93.      * The system error log.  If this is not open then error messages go
  94.      * to the console.
  95.      */
  96.     {DEV_SYSLOG,    Dev_SyslogOpen, Dev_SyslogRead, Dev_SyslogWrite,
  97.             Dev_SyslogIOControl, Dev_SyslogClose, Dev_SyslogSelect,
  98.             DEV_NO_ATTACH_PROC, Dev_SyslogReopen, noMmapProc},
  99.     /*
  100.      * SCSI Worm interface.
  101.      */
  102.     {DEV_SCSI_WORM, Dev_TimerOpen, Dev_TimerRead, nullWriteProc,
  103.             Dev_TimerIOControl, nullCloseProc, nullSelectProc,
  104.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  105.     /*
  106.      * The following device number is unused.
  107.      */
  108.     {DEV_PLACEHOLDER_2, noOpenProc, nullReadProc, nullWriteProc,
  109.             Dev_NullIOControl, nullCloseProc, Dev_NullSelect,
  110.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  111.     /*
  112.      * New SCSI Disk interface.
  113.      */
  114.     {DEV_SCSI_DISK, DevRawBlockDevOpen, DevRawBlockDevRead,
  115.             DevRawBlockDevWrite, DevRawBlockDevIOControl,
  116.             DevRawBlockDevClose, Dev_NullSelect, DevScsiDiskAttach,
  117.             DevRawBlockDevReopen, noMmapProc},
  118.     /*
  119.      * SCSI Tape interface.
  120.      */
  121.     {DEV_SCSI_TAPE, DevSCSITapeOpen, DevSCSITapeRead, DevSCSITapeWrite,
  122.             DevSCSITapeIOControl, DevSCSITapeClose, Dev_NullSelect,
  123.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  124.     /*
  125.      * /dev/null
  126.      */
  127.     {DEV_MEMORY,    nullOpenProc, Dev_NullRead, Dev_NullWrite,
  128.             Dev_NullIOControl, nullCloseProc, Dev_NullSelect,
  129.             DEV_NO_ATTACH_PROC, nullReopenProc, noMmapProc},
  130.     /*
  131.      * Xylogics 450 disk controller.
  132.      */
  133.     {DEV_XYLOGICS, DevRawBlockDevOpen, DevRawBlockDevRead,
  134.             DevRawBlockDevWrite, DevRawBlockDevIOControl, 
  135.             DevRawBlockDevClose, Dev_NullSelect,
  136.             DevXylogics450DiskAttach, DevRawBlockDevReopen,
  137.                     noMmapProc},
  138.     /*
  139.      * Network devices.  The unit number specifies the ethernet protocol number.
  140.      */
  141.     {DEV_NET,      DevNet_FsOpen, DevNet_FsRead, DevNet_FsWrite, 
  142.            DevNet_FsIOControl, DevNet_FsClose, DevNet_FsSelect, 
  143.            DEV_NO_ATTACH_PROC, DevNet_FsReopen, noMmapProc},
  144.     /*
  145.      * Raw SCSI HBA interface.
  146.      */
  147.     {DEV_SCSI_HBA, DevSCSIDeviceOpen, Dev_NullRead, Dev_NullWrite,
  148.             DevSCSIDeviceIOControl, DevSCSIDeviceClose, Dev_NullSelect,
  149.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  150.     /*
  151.      * RAID device.
  152.      */ 
  153.     {DEV_RAID, DevRawBlockDevOpen, DevRawBlockDevRead,
  154.                     DevRawBlockDevWrite, DevRawBlockDevIOControl,
  155.                     DevRawBlockDevClose, nullSelectProc, DevRaidAttach,
  156.                     DevRawBlockDevReopen, noMmapProc},
  157.     /*
  158.      * Debug device. (useful for debugging RAID device)
  159.      */ 
  160.     {DEV_DEBUG, DevRawBlockDevOpen, DevRawBlockDevRead,
  161.                     DevRawBlockDevWrite, DevRawBlockDevIOControl,
  162.                     DevRawBlockDevClose, nullSelectProc, DevDebugAttach,
  163.                     DevRawBlockDevReopen, noMmapProc},
  164.     /*
  165.      * Event devices for window systems.
  166.      */
  167.     {DEV_MOUSE,    DevMouseOpen, DevMouseRead, DevMouseWrite,
  168.            DevMouseIOControl, DevMouseClose, DevMouseSelect,
  169.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  170.     /*
  171.      * Frame buffer device.
  172.      */
  173.     {DEV_GRAPHICS, DevFBOpen, nullReadProc, nullWriteProc,
  174.                    DevFBIOControl, DevFBClose, nullSelectProc,
  175.                    DEV_NO_ATTACH_PROC, noReopenProc, DevFBMMap},
  176. };
  177.  
  178. int devNumDevices = sizeof(devFsOpTable) / sizeof(DevFsTypeOps);
  179.  
  180. static ReturnStatus
  181. nullOpenProc _ARGS_ ((Fs_Device *devicePtr,
  182.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr))
  183. {
  184.     return SUCCESS;
  185. }
  186.  
  187. static ReturnStatus
  188. noOpenProc _ARGS_ ((Fs_Device *devicePtr,
  189.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr))
  190. {
  191.     return FS_INVALID_ARG;
  192. }
  193.  
  194. static ReturnStatus
  195. nullReadProc _ARGS_ ((Fs_Device *devicePtr,
  196.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr))
  197. {
  198.     return SUCCESS;
  199. }
  200.  
  201. static ReturnStatus
  202. nullWriteProc _ARGS_ ((Fs_Device *devicePtr,
  203.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr))
  204. {
  205.     return SUCCESS;
  206. }
  207.  
  208. static ReturnStatus
  209. nullCloseProc _ARGS_ ((Fs_Device *devicePtr,
  210.     int flags, int numUsers, int numWriters))
  211. {
  212.     return SUCCESS;
  213. }
  214.  
  215. static ReturnStatus
  216. nullSelectProc _ARGS_ ((Fs_Device *devicePtr,
  217.     int *readPtr, int *writePtr, int *exceptPtr))
  218. {
  219.     return SUCCESS;
  220. }
  221.  
  222. static ReturnStatus
  223. nullReopenProc _ARGS_ ((Fs_Device *devicePtr,
  224.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr))
  225. {
  226.     return SUCCESS;
  227. }
  228.  
  229. static ReturnStatus
  230. noReopenProc _ARGS_ ((Fs_Device *devicePtr,
  231.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr))
  232. {
  233.     return FS_INVALID_ARG;
  234. }
  235.  
  236. static ReturnStatus
  237. noMmapProc _ARGS_ ((Fs_Device *devicePtr,
  238.     Address startAddr, int length, int offset, Address *newAddrPtr))
  239. {
  240.     return FS_INVALID_ARG;
  241. }
  242.  
  243.